home *** CD-ROM | disk | FTP | other *** search
- #
- # Test class for [incr Tcl] test suite
- # ----------------------------------------------------------------------
- # AUTHOR: Michael J. McLennan Phone: (215)770-2842
- # AT&T Bell Laboratories E-mail: aluxpo!mmc@att.com
- #
- # SCCS: @(#)Foo.tcl 1.3 (9/9/93)
- # ----------------------------------------------------------------------
- # Copyright (c) 1993 AT&T All Rights Reserved
- # ======================================================================
-
- itcl_class Foo {
- #
- # Constructor/destructor add their name to a global var for
- # tracking implicit constructors/destructors
- #
- constructor {config} {
- global WATCH
- lappend WATCH [info class]
- set foos($this) $this
- incr nfoo
- }
- destructor {
- global WATCH
- lappend WATCH [info class]
- unset foos($this)
- }
-
- method nothing {} {}
-
- method do {cmds} {
- return "Foo says '[eval $cmds]'"
- }
-
- #
- # Test methods using the "config" argument
- #
- method config {{config -blit auto -blat matic}} {
- return $config
- }
- method xconfig {x config} {
- return "$x|$config"
- }
- method configx {config x} {
- return "$config|$x"
- }
- method xecho {x args} {
- return "$x | [llength $args]: $args"
- }
-
- #
- # Test procs and access to common vars
- #
- proc echo {x args} {
- return "$x | [llength $args]: $args"
- }
- proc foos {{pattern *}} {
- set retn {}
- foreach i [array names foos] {
- if {$i != "_ignore_" && [string match $pattern $foos($i)]} {
- lappend retn $foos($i)
- }
- }
- return $retn
- }
- proc nfoos {} {
- return $nfoo
- }
-
- #
- # Test public/protected/common variable definitions
- #
- public blit
- public blat 0
- public blot 1 {global WATCH; set WATCH "blot=$blot"}
-
- protected _blit
- protected _blat 0
-
- common foos
- set foos(_ignore_) "foos-is-now-an-array"
-
- common nfoo 0
- }
-